Skip to content

test: cover native VM call argument packing#252

Draft
cursor[bot] wants to merge 1 commit into
next-gen-5from
cursor/missing-test-coverage-567f
Draft

test: cover native VM call argument packing#252
cursor[bot] wants to merge 1 commit into
next-gen-5from
cursor/missing-test-coverage-567f

Conversation

@cursor

@cursor cursor Bot commented Jun 10, 2026

Copy link
Copy Markdown

Summary

  • Added focused unit coverage for native VM vmMain argument packing.
  • Refactored the native VM_Call argument slot packing into the existing vm_native_module helper so the behavior is directly testable.
  • Updated tests/README.md to include unit_vm_native_module in the unit target index.

Risky behavior now covered

  • Native vmMain calls with fewer than three arguments now have tests proving missing argument slots are zero-filled.
  • Full three-argument native calls now have tests proving argument order is preserved.
  • The helper respects the native argument slot limit without writing beyond the provided array.

Test files added/updated

  • Updated tests/unit/test_vm_native_module.c
  • Updated tests/README.md

Why this reduces regression risk

Recent native VM loading fixes made standalone/full-conversion native modules more important. A regression in VM_Call argument packing can corrupt native UI/game module behavior, especially zero-argument calls like API-version probes that previously risked observing stack garbage. These unit tests pin that behavior without requiring game data or a graphics environment.

Validation

  • cmake --build build-coverage --target unit_vm_native_module && ctest --test-dir build-coverage -R '^unit_vm_native_module$' --output-on-failure — passed
  • cmake --build build-coverage --target idtech3_server — passed (pre-existing vm_x86.c variadic macro warnings only)
  • cmake --build build-coverage --target unit_macros unit_qmath unit_surfaceflags unit_qhelpers unit_crc unit_pathutil unit_msg unit_info unit_cm_bounds unit_parse unit_endian unit_vm_native_module && ctest --test-dir build-coverage -R '^unit_' --output-on-failure — 12/12 passed
Open in Web View Automation 

Co-authored-by: Tim Fox <timfox@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant